package org.frog.sgs.event;

import java.util.HashMap;
import java.util.Map;

import org.frog.sgs.character.Character;

/**
 * @author duanxiangqi
 * @date 2012-10-26
 */
public class SgsEvent {

	private int code;

	private Character character;

	private Map<Object, Object> attributes = new HashMap<Object, Object>();

	public SgsEvent() {}

	public SgsEvent(Character character, int code) {
		this.character = character;
		this.code = code;
	}

	public String getViewName() {
		return "{code:" + code + "," + character.getViewName() + ",attrs:" + attributes + "}";
	}

	public void setAttribute(Object key, Object value) {
		attributes.put(key, value);
	}

	public boolean hasAttribute(Object key) {
		return attributes.containsKey(key);
	}

	public void removeAttribute(Object key) {
		attributes.remove(key);
	}

	public Map<Object, Object> getAttributes() {
		return attributes;
	}

	public void setAttributes(Map<Object, Object> attributes) {
		this.attributes = attributes;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public Character getCharacter() {
		return character;
	}

	public void setCharacter(Character character) {
		this.character = character;
	}

	public String toString() {
		return getViewName();
	}
}
